package com.sc.nft.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.UserSynthesisRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sc.nft.entity.vo.AdminSynthesisRecordSimpleVO;
import com.sc.nft.entity.vo.AdminSynthesisRecordVO;
import com.sc.nft.entity.vo.SynthesisRecordVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * (sc_user_synthesis_record)数据Mapper
 *
 * @author rdg
 * @description 由 Mybatisplus Code Generator 创建
 * @since 2022-06-28 19:53:02
 */
@Mapper
public interface UserSynthesisRecordMapper extends BaseMapper<UserSynthesisRecord> {

    List<SynthesisRecordVO> synthesisRecord(@Param("userId") Long userId);

    Page<AdminSynthesisRecordVO> adminSynthesisRecord(Page page, @Param("nickName") String nickName, @Param("userTel") String userTel,
                                                      @Param("firstTitle") String firstTitle, @Param("startDate") Date startDate,
                                                      @Param("endDate") Date endDate);

    List<AdminSynthesisRecordSimpleVO> adminSynthesisRecordExport(@Param("productId") Long productId,
                                                                  @Param("startDate") Date startDate,
                                                                  @Param("endDate") Date endDate);

    /**
     * 查询用户合成某个商品的数量
     *
     * @param userId
     * @param productId
     * @return
     */
    Integer getCountByUserIdAndProductId(@Param("userId") Long userId, @Param("productId") Long productId);

    /**
     * @param start        起始条目
     * @param end          结束条目
     * @param orderId      查询区间订单号
     * @param collectionId 要查询的藏品id
     * @return
     */
    Integer findLimitBetween(@Param("start") Long start, @Param("end") Long end, @Param("orderId") Long orderId, @Param("collectionId") Integer collectionId);

    /**
     * 获取指定藏品id的全部有效数量
     *
     * @param collectionId
     * @return
     */
    Integer findLimitBetweenSum(@Param("collectionId") Integer collectionId);

    /**
     * 合成订单补偿
     *
     * @param start
     * @param end
     * @return
     */
    List<UserSynthesisRecord> compensation(@Param("start") Integer start, @Param("end") Integer end, @Param("collectionId") Long collectionId);

    Integer getYesterDayCountByCollectionId(@Param("collectionId") Long collectionId);

    Integer getYesterDayCountByCollectionIdByDay(@Param("collectionId") Long collectionId, @Param("day") String day);

    Integer getSumCountByCollectionId(@Param("collectionIds") List<Long> collectionId);
}
